import { BasicColumn, FormSchema } from "/@/components/Table"

export const tableColumns: BasicColumn[] = [
  {
    title: "表名称",
    dataIndex: "tableName",
    width: 200,
  },
  {
    title: "表描述",
    dataIndex: "comment",
    width: 300,
  },
]

export const searchTableFormSchema: FormSchema[] = [
  {
    field: "datasourceId",
    label: "数据源",
    component: "ApiSelect",
    // colProps: { span: 12 }
  },
  {
    label: "表名称",
    field: "tableName",
    component: "Input",
    // colProps: {span: 12}
  },
]

export const columns: BasicColumn[] = [
  {
    title: "数据源名称",
    dataIndex: "name",
    width: 120,
    align: "left",
  },
  {
    title: "数据库类型",
    dataIndex: "dbTypeText",
    width: 200,
  },
  {
    title: "Host",
    dataIndex: "host",
    width: 200,
  },
  {
    title: "Port",
    dataIndex: "port",
    width: 100,
  },
  {
    title: "用户名",
    dataIndex: "username",
    width: 100,
  },
]

export const searchFormSchema: FormSchema[] = [
  {
    field: "name",
    label: "数据源名称",
    component: "Input",
    colProps: { span: 8 },
  },
  {
    field: "dbType",
    label: "数据库类型",
    component: "JDictSelectTag",
    colProps: { span: 8 },
    componentProps: () => {
      return {
        dictType: "lcp_database_type",
      }
    },
  },
]

export const formSchema: FormSchema[] = [
  {
    field: "id",
    label: "id",
    component: "Input",
    show: false,
  },
  // {
  //   field: 'code',
  //   label: '数据源编码',
  //   component: 'Input',
  //   required: true,
  //   dynamicDisabled: ({ values }) => {
  //     return !!values.id;
  //   },
  // },
  {
    field: "name",
    label: "名称",
    component: "Input",
    required: true,
  },
  {
    field: "dbType",
    label: "类型",
    component: "JDictSelectTag",
    required: true,
    componentProps: ({ formModel }) => {
      return {
        dictType: "lcp_database_type",
        onChange: (e: any) => {
          // formModel = Object.assign(formModel, dbDriverMap[e], dbUrlMap[e]);
        },
      }
    },
  },
  // {
  //   field: 'dbDriver',
  //   label: '驱动类',
  //   required: true,
  //   component: 'Input',
  // },
  // {
  //   field: 'dbUrl',
  //   label: '数据源地址',
  //   required: true,
  //   component: 'Input',
  // },
  {
    field: "host",
    label: "Host",
    required: true,
    component: "Input",
  },
  {
    field: "port",
    label: "Port",
    required: true,
    component: "Input",
  },
  {
    field: "dbName",
    label: "数据库",
    required: true,
    component: "Input",
  },
  {
    field: "username",
    label: "用户名",
    required: true,
    component: "Input",
  },
  {
    field: "password",
    label: "密码",
    required: true,
    component: "InputPassword",
    slot: "pwd",
  },
  {
    field: "remark",
    label: "备注",
    component: "InputTextArea",
    componentProps: {
      autoSize: {
        minRows: 3,
        maxRows: 5,
      },
    },
  },
]
